<%@ tag description="Allows the project manager to apply a new target to an open issue" pageEncoding="UTF-8" %>
<%@ taglib prefix="iwebmvc" uri="http://tags.iwebmvc.com" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@ taglib uri="http://java.sun.com/jstl/core_rt" prefix="c-rt" %>
<%@ attribute name="issueClass" type="java.lang.Class" required="true" %>
<%@ attribute name="versionClass" type="java.lang.Class" required="true" %>
<c-rt:set var="sessionUser" value="<%= org.internna.iwebmvc.security.UserManager.SESSION_USER %>" />
<input type="hidden" id="targetIssueId" name="targetVersionId" />
<input type="hidden" id="targetVersionId" name="targetVersionId" />
<input type="hidden" id="targetVersionAlias" name="targetVersionAlias" />
<input type="hidden" id="targetVersionTree" name="targetVersionTree" />
<input type="hidden" id="targetVersionTreeContainer" name="targetVersionTreeContainer" />
<div class="overclear">
    <div id="targetVersionContainer" class="float_left" style="padding-top:3px;margin-right:5px"></div>
    <div class="float_right">
        <iwebmvc:button buttonId="targetVersionButton" label="ui.issue.actions.administrator.target.save" buttonIcon="/resource.iwebmvc?file=/images/common/applyversion_${sessionScope[sessionUser].theme}.gif">
            byId("targetVersionValidationWarningContainer").innerHTML = "";
            dijit.byId("targetVersionButton").setDisabled(true);
            var issue = dwr.engine.remote.newObject('${iwebmvc:inferDWRConvertedJavascriptClass(issueClass)}', {id: byId("targetIssueId").value});
            var version = dwr.engine.remote.newObject('${iwebmvc:inferDWRConvertedJavascriptClass(versionClass)}', {id: byId("targetVersionId").value, parentProject: null, parentVersion: null});
            RemoteIssueManager.applyTargetVersion(issue, version, function (data) {
                if (data) {
                    byId("targetVersionValidationWarningContainer").innerHTML = data;
                } else {
                    closePopup("targetversion");
                    placebackTargetVersionSelector();
                    var alias = byId("targetVersionAlias").value;
                    refreshAllActivities(alias);
                    byId(alias + "TargetDisplayContainer").innerHTML = dijit.byId(alias.substring(0, alias.lastIndexOf("-")) + "VersionTree").lastFocused.label;
                }
            });
        </iwebmvc:button>
        <div id="targetVersionValidationWarningContainer" class="validationWarning"></div>
    </div>
</div>